package com.ruoyi.lvlian.domain;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.Serializable;
import java.util.Arrays;

/**
 * 汽车轨迹实体类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MapLabel implements Serializable {
    private static final long serialVersionUID = 1L;

    private Double[] position;
    private String location;
    /**
     * 原始地址
     */
    @Excel(name = "原始地址")
    private String parkAdr;

    /**
     * 标签
     */
    @Excel(name = "标签")
    private String label;

    /**
     * 停留时长
     */
    @Excel(name = "停留时长")
    private Integer parkMins;

    /**
     * 标记地址
     */
    @Excel(name = "标记地址")
    private String addr;
    private String remark;

    public String getLocation() {
        if (StringUtils.isNotEmpty(position)) {
            return Arrays.toString(position).replaceAll(" ", "");
        }
        return location;
    }

    public Double[] getPosition() {
        if (position == null && StringUtils.isNotEmpty(location)) {
            return Arrays.stream(location.replaceAll("[\\[\\]]", "").split(","))
                    .map(String::trim)  // 去除空格
                    .map(Double::parseDouble)
                    .toArray(Double[]::new);

        }

        return position;
    }

    private int index;
}
